package map;

import java.util.*;

//遍历map
public class MapDemo2 {
    public static void main(String[] args) {
        Map<String,Integer> map=new HashMap<>();
        map.put("语文",100);
        map.put("数学",150);
        map.put("英语",85);
        map.put("体育",65);
        map.put("java",99);
        System.out.println(map);
       /* Set<String> keySet=map.keySet();
        for (String key:keySet){
            System.out.println("key"+key);
        }
        Set<Map.Entry<String,Integer>> entrySet=map.entrySet();
        for (Map.Entry<String,Integer> entry:entrySet){
            String key=entry.getKey();
            Integer value=entry.getValue();
            System.out.println(key+","+value);
        }
        Collection<Integer> values=map.values();
        for (Integer value:values){
            System.out.println("value:"+values);
        }*/
        //lambda 集合遍历
        /*Map<String,Integer> c=new HashMap<>();
        c.forEach(s -> System.out.println(s));
*/
        map.forEach((k,v)-> System.out.println(k+","+v));
    }
}
